<template>
  <div class="login-container"
       @keyup.enter.native="handleLogin">
    <img src="/img/login/bg.png" width="100%" style="position: absolute;margin-top: 429px;">
    <top-color v-show="false"></top-color>
    <div class="login-weaper animated bounceInDown">
      <div class="login-left">
        <img src="/img/login/login_logo.png" width="100%" height="100%" style="position: absolute">
        <div class="login-time">
          {{ time }}
        </div>
        <img class="img"
             src="/img/login/star-squashed"
             alt="">
        <p class="title">{{ $t('login.info') }}</p>

      </div>
      <div class="login-border">
        <div class="login-main">
          <h4 class="login-title">
            {{ $t('login.title') }}{{ website.title }}
            <top-lang></top-lang>
          </h4>
          <userLogin v-if="activeName==='user'"></userLogin>
          <codeLogin v-else-if="activeName==='code'"></codeLogin>
          <thirdLogin v-else-if="activeName==='thidr'"></thirdLogin>
          <faceLogin v-else-if="activeName==='face'"></faceLogin>
          <div class="login-menu">
            <a href="#" @click.stop="activeName='user'">{{ $t('login.userLogin') }}</a>
            <a href="#" @click.stop="activeName='code'">{{ $t('login.phoneLogin') }}</a>
            <a href="#" @click.stop="activeName='face'">{{ $t('login.faceLogin') }}</a>
            <a href="#" @click.stop="activeName='third'">{{ $t('login.thirdLogin') }}</a>
          </div>
        </div>

      </div>
    </div>
  </div>
</template>
<script>
import userLogin from "./userlogin";
import codeLogin from "./codelogin";
import thirdLogin from "./thirdlogin";
import faceLogin from "./facelogin";
import {mapGetters} from "vuex";
import {dateFormat} from "@/utils/date";
import {validatenull} from "@/utils/validate";
import topLang from "@/page/index/top/top-lang";
import topColor from "@/page/index/top/top-color";

export default {
  name: "login",
  components: {
    userLogin,
    codeLogin,
    thirdLogin,
    faceLogin,
    topLang,
    topColor
  },
  computed: {
    ...mapGetters(["website"])
  },
  props: [],
  data() {
    return {
      time: "",
      activeName: "user"
    };
  },
  watch: {
    $route() {
      const params = this.$route.query;
      this.socialForm.state = params.state;
      this.socialForm.code = params.code;
      if (!validatenull(this.socialForm.state)) {
        const loading = this.$loading({
          lock: true,
          text: `${
              this.socialForm.state === "WX" ? "微信" : "QQ"
          }登录中,请稍后。。。`,
          spinner: "el-icon-loading"
        });
        setTimeout(() => {
          loading.close();
        }, 2000);
      }
    }
  },
  created() {

    this.getTime();
    setInterval(() => {
      this.getTime();
    }, 1000);

  },
  mounted() {
    this.loadSecurity()
  },
  methods: {
    getTime() {
      this.time = dateFormat(new Date());
    },
    loadSecurity() {
      console.log("加载密钥")
      this.$store.dispatch("loadSecurityData").then(res => {

      })
    }

  }
};
</script>

<style lang="scss">
@import "@/styles/login.scss";
</style>
